<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>制定计划</title>
<link th:href="@{/ksdH5/css/public/mui/mui.css}" rel="stylesheet"/>
<script th:src="@{/ksdH5/js/public/mui/mui.min.js}"></script>
<script th:src="@{/ksdH5/js/public/kalendae.standalone.js}"></script>
<link th:href="@{/ksdH5/css/public/kalendae.css}" rel="stylesheet" />
<link th:href="@{/ksdH5/css/public/dizhi.css}" rel="stylesheet" />
<script th:src="@{/ksdH5/js/public/jquery.min.js}"></script>
<script th:src="@{/ksdH5/js/public/public.js}"></script>
<link th:href="@{/ksdH5/css/public/leftNav.css}" rel="stylesheet"/>
<link th:href="@{/ksdH5/css/planList/makePlan.css}" rel="stylesheet"/>
</head>
<body>
<!--头部-->
<div class="headerBox">
	<a href="javascript:void(0);" class="headerBox_left"><img th:src="@{/ksdH5/img/header_leftIcon.png}"></a>
	<!--关闭按钮-->
	<a href="javascript:void(0);" class="headerBox_leftClose"><img th:src="@{/ksdH5/img/login/closeBnt.png}"></a>
	<span>制定计划</span>
	<a href="javascript:void(0);" class="headerBox_right" onclick="viewPlan()">预览</a>
</div>
<div class="mui-content">
	<a href="javascript:void(0);" class="cardDetails_noCardBox" >
        <div class="cardDetails_noCardBox_img">
            <img th:src="@{/ksdH5/img/zdjh_addBnt.png}" />
        </div>
        <div class="cardDetails_noCardBox_cont">请选择信用卡</div>
    </a>
    <div class="cardDetails_CardBox" style="display: none;" >
        <div class="cardManagementBox_li">
            <div class="cardManagementBox_yhkBnt">
                <img class="cardManagementBox_cardBg" th:src="@{/ksdH5/img/zwt/yhBg.png}" />
                <div class="cardManagementBox_box" id="current_card_div">
                    <!-- <div class="cardManagementBox_left">
                        <img th:src="@{/ksdH5/img/zwt/msyh_logo.png}" />
                    </div>
                    <div class="cardManagementBox_middle">
                        <div class="cardManagementBox_middle_top">
                            <span>华夏银行</span>
                            <em>李敏</em>
                        </div>
                        <div class="cardManagementBox_middle_middle">1997********0235</div>
                        <div class="cardManagementBox_middle_bottom">
                            <span>账单日
                                <em>18日</em></span>
                            <span>还款日
                                <em>28日</em></span>
                        </div>
                    </div>
                    <div class="cardManagementBox_right"></div> -->
                </div>
            </div>
        </div>
    </div>
    <div class="cardDetails_segmentation"></div>
    <div class="addCreditCard_tishiBox">
        <img th:src="@{/ksdH5/img/ggBg.png}" />结束日请早于还款日1天以上且还款金额稍大于账单金额
    </div>
    <div class="cardDetails_segmentation"></div>
    <div class="cardDetails_contBox">
    	<div class="cardDetails_contBox_cont">
    		<div class="cardDetails_contBox_cont_box">
    			<span class="cardDetails_contBox_cont_box_left   ">还款金额</span>
    			<input type="tel" onkeyup="value=zhzs(this.value)"  id="planMoney" class="change_input" placeholder="请输入还款金额" />
    		</div>
    		<div class="cardDetails_contBox_cont_box">
    			<span class="cardDetails_contBox_cont_box_left">还款日期</span>
    			<div onclick="dateClick()" class="cardDetails_contBox_cont_timeBoxNo" id="showTime" >
    				请选择还款日期
    			</div>
    		</div>
			<div class="cardDetails_contBox_cont_timeBox_time" style="display: none;">
                <div id="planTime"></div>
            </div>
    	</div>
    </div>
    <div class="cardDetails_titleBox">
    	请选择还款次数/城市
    </div>
    <div class="cardDetails_chengshiBox change_div">
    	<div class="cardDetails_chengshiBox_cishu change_div">1次/日</div>
    	<div class="cardDetails_chengshiBox_cishu change_div">2次/日</div>
    	<div class="cardDetails_chengshiBox_cishu change_div">3次/日</div>
    	<div class="cardDetails_chengshiBox_chengshi">
    		<input type="text" id="city_input" class="select-value change_input" value="请选择城市">
    	</div>
    </div>
    <div class="cardDetails_titleBox makePlan_jihua">
    	<span>点击显示周转金</span>
    	<em class="total_zhj" id="total_zhj"></em>
    </div>
    <div class="makePlan_jihua_contBox" style="display: none;">
    	<div class="makePlan_jihua_contBox_topBox">
    		<div class="makePlan_jihua_contBox_topBox_top">
    			<p>
    				<span>周转金总额</span>
    				<strong class="total_zhj"></strong>
    			</p>
    			<em>注:计划完成后会退还<span id="THMoney"></span>元到信用卡</em>
    		</div>
    		<div class="makePlan_jihua_contBox_line"></div>
    		<div class="makePlan_jihua_contBox_topBox_top makePlan_jihua_contBox_topBox_box">
    			<p>
    				<span>还款手续费</span>
    				<strong id="rate_money"></strong>
    			</p>
    			<em><i>注:还款金额 × <span id="scale"></span></i></em>
    		</div>
    		<div class="makePlan_jihua_contBox_topBox_top makePlan_jihua_contBox_topBox_box">
    			<p>
    				<span>还款笔数费</span>
    				<strong id="times_money"></strong>
    			</p>
    			<em><i>注:还款笔数费 1元/笔</i></em>
    		</div>
    		<div class="makePlan_jihua_contBox_topBox_top makePlan_jihua_contBox_topBox_box">
    			<p>
    				<span>周转金手续费</span>
    				<strong id="free_free"></strong>
    			</p>
    			<em><i>注:交易过程中手续费本身产生的手续费</i></em>
    		</div>
    		<div class="makePlan_jihua_contBox_diandian">
    			<img th:src="@{/ksdH5/img/fgxBg.png}" />
    		</div>
    		<div class="makePlan_jihua_contBox_bottom">
    			<span>手续费总额</span>
    			<em id="toalFree"></em>
    		</div>
    	</div>
    	<div class="makePlan_jihua_contBox_bottomBox">
    		<img th:src="@{/ksdH5/img/makePlan_gantanhao.png}" />请确保卡内剩余额度大于<span class="total_zhj"></span>元，以免计划失败！
    	</div>
    </div>
    <div class="cardDetails_bntBox">
    	<button onclick="showTransPassord()">提交计划</button>
    </div>
</div>

<!--通道提示框-->
<div class="selectChannelBox_tishiBg"></div>
<div class="selectChannelBox_tishiBox" style="display: none;">
	<div class="selectChannelBox_tishiBox_top">
		<a href="javascript:void(0);" class="selectChannelBox_tishiBox_top_close"><img th:src="@{/ksdH5/img/selectChannel_close.png}" /></a>
	</div>
	<div class="selectChannelBox_tishiBox_middle">
		<div class="s_t_m_top"><img th:src="@{/ksdH5/img/yinlianLogo.png}" />开通通道</div>
		<div class="s_t_m_middle">
			<span>信用卡：</span>
			<em id="open_acq_cardno"></em>
		</div>
		<div class="s_t_m_middle">
			<span>手机号：</span>
			<em id="open_bank_phone"></em>
		</div>
		<div class="s_t_m_bottom">
			<strong>验证码：  </strong>
			<input type="text" id="open_acq_code" placeholder="输入验证码" />
			<a href="javascript:void(0);" class="T-getCode" onclick="getOpenCode()">获取验证码</a>
			<span class="T-getCode1"></span>
		</div>
	</div>
	<button class="selectChannelBox_tishiBox_bnt" onclick="submitAcq()">确定</button>
</div>

<!--左侧导航-->
<!-- 引入导航页面 -->

<!-- ecr/html/includeNav:是子页面的文件路径 ；myNav：是子页面中被引用代码块的名称
（如th:fragment="myNav"） -->
<div th:replace="h5/ksdH5IncludeNav :: ksdH5Nav"  ></div>

<!--选择信用卡-->
<div class="makePlan_xkBg" style="display: none;"></div>
<div class="makePlan_selectedCardBox" style="display: none;">
	<div class="makePlan_selectedCardBox_topBox">
		<span>选择信用卡</span>
		<a href="javascript:void(0);" class="makePlan_selectedCardBox_closeBnt"><img th:src="@{/ksdH5/img/login/closeBnt.png}" /></a>
	</div>
	<div id="card_list_div" class="makePlan_selectedCardBox_listBox">
		
	</div>
</div>
<div class="huiseBox"></div>

<!--预览-->
<div class="planCont_xkBg" style="display: none;"></div>
<div class="planContBox" style="display: none;">
	<div class="planContBox_top">
		<span>制定计划</span>
		<a href="javascript:void(0);" class="planContBox_closeBnt"><img th:src="@{/ksdH5/img/login/closeBnt.png}" /></a>
	</div>
	<div class="planContBox_contBox">
		<div class="palnCont_topBox">
			<div class="palnCont_topBox_top">
				<div class="palnCont_topBox_top_left">
					<img id="bankImg" th:src="@{/ksdH5/img/zwt/yhLOGO.png}" />
				</div>
				<div class="palnCont_topBox_top_middle">
					<strong id="bankName">（<span id="bankEndNo"></span>）</strong>
					<span id="cityName"></span>
				</div>
			</div>
			<div class="palnCont_topBox_middle">
				<span id="plan_time"></span>
				<em>待制定</em>
			</div>
			<div class="palnCont_topBox_bottom">
				<div class="palnCont_topBox_bottom_left">
					<span>还款形式</span>
					<strong><em id="second"></em>笔/日</strong>
				</div>
				<div class="palnCont_topBox_bottom_middle">
					<span>计划还款</span>
					<strong id="plan_money_strong"></strong>
				</div>
				<div class="palnCont_topBox_bottom_right">
					<span>周转金</span>
					<strong class="total_zhj"></strong>
				</div>
			</div>
	<!-- 		<div class="palnCont_topBox_bottom">
				<div class="palnCont_topBox_bottom_left">
					<span>实际还款</span>
					<strong></strong>
				</div>
				<div class="palnCont_topBox_bottom_middle">
					<span>实扣手续费</span>
					<strong></strong>
				</div>
				<div class="palnCont_topBox_bottom_right">
					<span>进度</span>
					<strong></strong>
				</div>
			</div> -->
			<div class="lineBox">
				<img th:src="@{/ksdH5/img/planList/fgxBg.png}" />
			</div>
		</div>
		<ul class="palnCont_listBox" id="item_list_ul">
	
			
			<!-- <li>
				<div class="palnCont_listBox_topBox">2018年12月12日</div>
				<div class="palnCont_listBox_bottomBox">
					<img th:src="@{/ksdH5/img/planList/huankuanfangshi.png}" />
					<strong>消费</strong>
					<span class="palnCont_color_lvse">已执行 </span>
					<em>5750,70</em>
				</div>
				<div class="palnCont_listBox_bottomBox">
					<img th:src="@{/ksdH5/img/planList/hkfs_hsIcon.png}" />
					<strong>退款</strong>
					<span class="palnCont_color_lvse">待执行</span>
					<em>5750,70</em>
				</div>
			</li> -->
		</ul>
	</div>
</div>

<!--输入交易密码框-->
<div class="tradePassword_tishiBg" ></div>
<div class="tradePassword_tishiBox" >
	<div class="selectChannelBox_tishiBox_top">
		<a href="javascript:void(0);" class="tradePassword_tishiBox_close"><img th:src="@{/ksdH5/img//selectChannel_close.png}" /></a>
	</div>
	<div class="selectChannelBox_tishiBox_middle">
		<div class="s_t_m_top">交易密码</div>
		<div class="s_t_m_bottom tradePassword_bottom">
			<strong>交易密码：</strong>
			<input id="tranPassword" type="password" placeholder="输入交易密码" />
		</div>
	</div>
	<button class="selectChannelBox_tishiBox_bnt"  onclick="submitPlan()">确定</button>
	<span class="cardDetails_bntBox_nobnt"></span>
</div>
</body>
<script type="text/javascript" th:inline="javascript">
//获得项目根路径
var ctx = [[@{/}]];
</script>
 <script type="text/javascript">
 var bigRate;
 var smallRate;
 
 var prefix = ctx +"h5";
    	$(function(){
    		//指定第一个菜单样式选中
    		$(".leftNavContBox_contBox li").eq(0).find("a").addClass('leftNavContBox_contBox_bnt_active');
    		//查询用户信息
    		 $.ajax({
					url : ctx+ "h5/merInfo",
					type : "POST",
					success : function(re) {
					if (re.status == "SUCCESS") {
						var merchant = re.merchant;
						$("#nav_mer_name").text(merchant.merchantCnName);
						$("#nav_mer_phone").text(merchant.phone);
						var level = merchant.level;
						if(level=="1"){
							$("#nav_mer_level").text("免费用户");
						} else if(level=="2"){
							$("#nav_mer_level").text("经理（未激活）");
						} else if(level=="3"){
							$("#nav_mer_level").text("经理");
						}
						//指定头像
						var headImg = re.headImg;
						if(headImg != ""&& headImg !=null){
							$("#head_img").attr('src',headImg);
						}
					} else {
						
					}
				}
			}); 
    		//查询用户卡包信息
    		 $.ajax({
					url : prefix+"/card/list",
					type : "POST",
					success : function(re) {
					if (re.status == "out") { //session过期
						//跳转登陆页面
						location.href = prefix + '/login';
					} else {
						
					}
				}
			}); 
    		
    		
    	})
    </script>
<script type="text/javascript">
mui.init({
	swipeBack:true
})

/*打开新的下载页面窗口*/
$(document).on('click','#uploadBnt',function(){
	window.open("https://fir.im/Katimes");
})

/*左边导航*/
$(document).on('click','.headerBox_left',function(){
	$('.huiseBox').show();
	$('.leftNavContBox').show();
	$('.headerBox_leftClose').show();
	$('.headerBox_left').hide();
	$("body").attr("style","left:5.48rem;position:fixed;"); 
	$(".headerBox").css('left','5.48rem');   
});
$(document).on('click','.headerBox_leftClose',function(){
	$('.huiseBox').hide();
	$('.leftNavContBox').hide();
	$('.headerBox_leftClose').hide();
	$('.headerBox_left').show();
	$("body").removeAttr("style");   
	$("body").removeAttr("style"); 
	$(".headerBox").css('left','0');   
});
/*选择日期JS*/
 function dateClick(){
	 $('.cardDetails_contBox_cont_timeBox_time').toggle();
    $('.cardDetails_contBox_cont_timeBoxNo').toggleClass('cardDetails_contBox_cont_timeBox_name');
}
 
var times = ""; //时间集合字符串
var timeArray = new Array(); //日期数组
var items;
var plan;
var limitId;
new Kalendae(document.getElementById("planTime"), {
    months: 1,
    mode: 'multiple',
    direction: 'future',
    subscribe: {
        'change': function(date) {
            times = (date._i, this.getSelected());
            if(times == null || times == ""){
            	$("#showTime").html('请选择还款日期');
            	return;
            }
            timeArray = times.split(",");
            var newTimsStr = "";
            $.each(timeArray,
            function(index, value) {
                if (value.trim().substring(5, 7) > 9) {
                    newTimsStr += "<strong>" + value.trim().substr(5) + "</strong>";
                } else {
                    newTimsStr += "<strong>" + value.trim().substr(6) + "</strong>";
                }
            });
            $("#showTime").html(newTimsStr.substr(0, newTimsStr.length - 2));
            clearIput();
        }
    }
});
/*选择次数JS*/
var second; //每天执行次数
var cardList;//全局变量卡列表
var currentCardNo="";//全局变量当前选中的卡号
var currentCardId="";//全局变量当前选中信用卡id
var acqCode="";//全局变量通道编号
var list ="";//全局变量计划明细列表
var planDate ="";//全局变量计划执行时间区间
var  iskt = false;//是否开通了通道
var kt_phone;

/*弹出选卡页面*/
$(document).on('click', '.cardDetails_noCardBox',function() {
    $('.makePlan_xkBg').show('');
    $('.makePlan_selectedCardBox').show('');
});
/*关闭选卡页面*/
$(document).on('click', '.makePlan_selectedCardBox_closeBnt',function() {
    $('.makePlan_xkBg').hide('');
    $('.makePlan_selectedCardBox').hide('');
});
 /*点击问号*/
 /*
$(document).on('click','.makePlan_jihua_contBox_topBox_box_sxfmx',function(){
	 mui.alert('周转金大于1000元(包含1000)使用大额费率<br/>周转金小于1000元使用小额费率<br/>我的费率：大额:'+bigRate+'，小额 ：'+smallRate+'','费率说明')
	}); */
/*预览制定计划*/
$(document).on('click','.headerBox_right',function(){
   	
})
$(document).on('click','.planContBox_closeBnt',function(){
    $('.planCont_xkBg').hide('');
    $('.planContBox').hide('');			
})
/*交易密码提示框关闭*/
$(document).on('click','.tradePassword_tishiBox_close',function(){
	$(".tradePassword_tishiBox").hide();
	$(".tradePassword_tishiBg").hide();
})
</script>
<script type="text/javascript">
/*选择通道*/
$(document).on('click','.cardDetails_bntBox_bnt',function(){
    $('.selectChannelBox_tishiBg').show('');
    $('.selectChannelBox_tishiBox').show('');	
});
$(document).on('click','.selectChannelBox_tishiBox_top_close',function(){
	$('.selectChannelBox_tishiBg').hide();
    $('.selectChannelBox_tishiBox').hide();
});
</script>
<script type="text/javascript">
//获取短信验证码
$(function(){
    var validCode=true;
    $(".T-getCode").click (function  () {
        var time=60;
        var $code=$(this);
        if (validCode) {
            validCode=false;
            var t=setInterval(function  () {
                time--;
                $(".T-getCode").hide();
                $(".T-getCode1").show();
                $(".T-getCode1").html(time+"秒");
                if (time==0) {
                    clearInterval(t);
                    $(".T-getCode").html("重新获取");
		            $(".T-getCode1").hide();
                	$(".T-getCode").show();
                    validCode=true;
                }
            },1000)
        }
    })
    
	//防止重复提交事件
	var validCode=true;
    $(".selectChannelBox_tishiBox_bnt").click (function  () {
        var time=30;
        var $code=$(this);
        if (validCode) {
            validCode=false;
            var t=setInterval(function  () {
                time--;
                $(".selectChannelBox_tishiBox_bnt").hide();
                $(".cardDetails_bntBox_nobnt").show();
                $(".cardDetails_bntBox_nobnt").html(time+"秒");
                if (time==0) {
                    clearInterval(t);
                    $(".selectChannelBox_tishiBox_bnt").html("提交计划");
		            $(".cardDetails_bntBox_nobnt").hide();
                	$(".selectChannelBox_tishiBox_bnt").show();
                    validCode=true;
                }
            },1000)
        }
    })
    
  //选择次数
	 $('.cardDetails_chengshiBox_cishu').click(function() {
	    $('.cardDetails_chengshiBox_cishu').removeClass('cardDetails_chengshiBox_cishu_active');
	    $(this).addClass('cardDetails_chengshiBox_cishu_active');
	    second =  $(this).text().substr(0,1);
	});
   
    /*查看周转金额JS*/
   	 $('.makePlan_jihua').click(function() {
   		 
   		var display =$('.makePlan_jihua_contBox').css('display');
   		if(display == 'none'){
   			 var isGonOn = getItems();
   			 if(isGonOn == undefined || isGonOn==true){
   				 $('.makePlan_jihua_contBox').toggle('');
   		        $('.makePlan_jihua strong').toggleClass('cardDetails_titleBox_active');
   			 }
   		} else {
   		 $('.makePlan_jihua_contBox').toggle('');
	        $('.makePlan_jihua strong').toggleClass('cardDetails_titleBox_active');
   		}
       
    });
})


//转化正整数
function zhzs(value){
    value = value.replace(/[^\d]/g,'');
    if(''!=value){
        value = parseInt(value);
    }
    return value;

}

</script>


<script th:src="@{/ksdH5/js/public/dizhi.js}"></script>

<script type="text/javascript">
	$(function(){
 		//查询信用卡列表
		  $.ajax({
				url : ctx+ "h5/card/list",
				type : "POST",
				success : function(re) {
				if(re.status == "out"){
					//跳转登陆页面
					location.href = ctx + 'h5/login';
				}	
				if (re.status == "SUCCESS") {
					//var cardList =JSON.parse(re.obj.CCList);
					cardList =re.list;
					 if(cardList.length==0){
						$("#no_have_data").show();
					} else {
						$("#no_have_data").hide();
					}
					//遍历json数组字符串
					var cardStr ="";
					$.each(cardList,function(index,obj){
						cardStr += '<a href="javascript:void(0);" onclick="chooseCard(\''+obj.id+'\')">';	
						cardStr += "<img class='makePlan_selectedCardBox_listBox_cardBG' src='/ksdH5/img/zwt/yhBg.png' />";	
						cardStr += "<div class='makePlan_selectedCardBox_listBox_contBox'>";	
						cardStr += "<div class='cardManagementBox_left'>";	
						cardStr += "<img src='"+obj.ccImg+"' />";	
						cardStr += "</div>";	
						cardStr += "<div class='cardManagementBox_middle'>";	
						cardStr += " <div class='cardManagementBox_middle_top'>";	
						cardStr += "<span>"+obj.bankName+"</span>";
						cardStr +=  "<em>"+obj.bankAccountName+"</em>";
						cardStr +=  "</div>";
						cardStr +=  " <div class='cardManagementBox_middle_middle'>"+obj.bankAccount.substr(0,4)+"&nbsp;&nbsp;&nbsp;&nbsp;****&nbsp;&nbsp;&nbsp;&nbsp;****&nbsp;&nbsp;&nbsp;&nbsp;"+obj.bankAccount.substr(obj.bankAccount.length-4)+"</div>";
						cardStr +=  "</div>";	
						cardStr +=  " <div class='planList_listBox_right_bottom'>";	
						cardStr +=  " <div class='planList_listBox_right_bottom_left'>";	
						cardStr +=  "<span>额度</span>";	
						cardStr +=  "<strong>"+obj.limitMoney+"</strong>";	
						cardStr +=  "</div>";	
						cardStr +=  "<div class='planList_listBox_right_bottom_left'>";	
						cardStr +=  "<span>账单日</span>";	
						cardStr +=  "<strong>"+obj.billDay+"</strong>";	
						cardStr +=  "</div>";	
						cardStr +=  "<div class='planList_listBox_right_bottom_left'>";	
						cardStr +=  "<span>还款日</span>";	
						cardStr +=  "<strong>"+obj.repaymentDay+"</strong>";	
						cardStr +=  "</div>";	
						cardStr +=  "</div>";	
						cardStr +=  "</div>";	
						cardStr +=  "</a>";	
				　　}); 
					$("#card_list_div").html(cardStr);
				} else {
					
				}
			}
		});  
		
	})
	
	//选择信用卡
	function chooseCard(id){
		if(cardList.length>0){
			var cardStr="";
			$.each(cardList,function(index,obj)　{
				if(cardList[index].id==id){
					currentCardId = id;
					var obj = cardList[index];
					cardStr += "<img class='makePlan_selectedCardBox_listBox_cardBG' src='/ksdH5/img/zwt/yhBg.png' />";	
					cardStr += "<div class='makePlan_selectedCardBox_listBox_contBox'>";	
					cardStr += "<div class='cardManagementBox_left'>";	
					cardStr += "<img src='"+obj.ccImg+"' />";	
					cardStr += "</div>";	
					cardStr += "<div class='cardManagementBox_middle'>";	
					cardStr += " <div class='cardManagementBox_middle_top'>";	
					cardStr += "<span>"+obj.bankName+"</span>";
					cardStr +=  "<em>"+obj.bankAccountName+"</em>";
					cardStr +=  "</div>";
					currentCardNo = obj.bankAccount
					cardStr +=  " <div class='cardManagementBox_middle_middle'>"+obj.bankAccount.substr(0,4)+"&nbsp;&nbsp;&nbsp;&nbsp;****&nbsp;&nbsp;&nbsp;&nbsp;****&nbsp;&nbsp;&nbsp;&nbsp;"+obj.bankAccount.substr(obj.bankAccount.length-4)+"</div>";
					cardStr +=  "</div>";	
					cardStr +=  " <div class='planList_listBox_right_bottom'>";	
					cardStr +=  " <div class='planList_listBox_right_bottom_left'>";	
					cardStr +=  "<span>额度</span>";	
					cardStr +=  "<strong>"+obj.limitMoney+"</strong>";	
					cardStr +=  "</div>";	
					cardStr +=  "<div class='planList_listBox_right_bottom_left'>";	
					cardStr +=  "<span>账单日</span>";	
					cardStr +=  "<strong>"+obj.billDay+"</strong>";	
					cardStr +=  "</div>";	
					cardStr +=  "<div class='planList_listBox_right_bottom_left'>";	
					cardStr +=  "<span>还款日</span>";	
					cardStr +=  "<strong>"+obj.repaymentDay+"</strong>";	
					cardStr +=  "</div>";	
					cardStr +=  "</div>";	
					$("#current_card_div").html(cardStr);//选中的信用卡
					$(".cardDetails_noCardBox").hide();//选择卡“+”隐藏
					$(".cardDetails_CardBox").show();//当前已选卡信息显示
					//关闭信用卡列表
					$('.makePlan_xkBg').hide('');
				    $('.makePlan_selectedCardBox').hide('');
				    //给预览提示框里面绑定值
				    $("#bankName").text(obj.bankName);
				    $("#bankEndNo").text(currentCardNo.substr(currentCardNo.length-4));
				    $("#bankImg").attr("src",obj.ccImg);
				}
			})
		}
	}
//预览计划
function  viewPlan(){
		if(currentCardNo==""||currentCardId==""){
			mui.toast("请选择信用卡",{ duration:'long'});
			return;
		}
		var planMoney = $("#planMoney").val();
		if(""==planMoney || planMoney==null){
			mui.toast("输入还款金额",{ duration:'long'});
			return;
		}
		var dateStr =times;
		if(timeArray.length<2){
			mui.toast("日期最少选择两天",{ duration:'long'});
			return;
		}
		if(""==second || second==null){
			mui.toast("请选择还款次数",{ duration:'long'});
			return;
		}
		var cityName =$("#city_input").val();
		if("请选择城市"==cityName){
			mui.toast("请选择城市",{ duration:'long'});
			return;
		}
		var cardNo = currentCardNo;
		var bindID =currentCardId;
		  $.ajax({
				url : ctx+ "h5/plan/add",
				type : "POST",
				data:{
					"cityName":cityName,
					"planMoney":planMoney,
					"dateStr":dateStr,
					"cardNo":cardNo,
					"second":second,
					"bindID":bindID
				},
				success : function(re) {
				if(re.status == "out"){
					//跳转登陆页面
					location.href = ctx + 'h5/login';
				}	
				if (re.status == "SUCCESS") {
					var obj = re.obj;
					kt_phone = obj.kt_phone;
					if(kt_phone != null){//需要开通通道
						//弹出开通通道提示框
						checkAcqKt();
						acqCode = obj.kt_code;
				    	return;
				    }else {
				    	iskt = true;
				    }
					acqCode = obj.acq_code;
					list = obj.list;
					var bigfl = obj.bigfl;//大额费率
					var free_free = obj.free_free;//手续费的手续费
					$("#free_free").text(free_free.toFixed(2));
					var plan_time = obj.plan_time;//执行时间区间 例如2019/07/17 - 2019/07/19
					planDate = plan_time;
					var province_city = obj.province_city; //落地城市 例如：湖北省-武汉市
					var rate_money = obj.rate_money;
					$("#rate_money").text(rate_money.toFixed(2));
					var sbigorsmall = obj.sbigorsmall; //大额 或者 小额
					$("#sbigorsmall").text(sbigorsmall);
					var scale = obj.scale; //当前费率
					$("#scale").text(scale);
					var second = obj.second; //每天执行次数 
					$("#second").text(second);
					var smallfl = obj.smallfl; //小额费率
					var times_money = obj.times_money; //笔数费
					$("#times_money").text(times_money.toFixed(2));
					var toalFree = obj.toalFree; //手续费总额
					$("#toalFree").text(toalFree.toFixed(2));
					var total_zhj = obj.total_zhj; //周转金
					$(".total_zhj").text(total_zhj.toFixed(2));
					
					 //接收计划明细
					var items =$.parseJSON(obj.formatItmes) ;//把json字符串转javascript json对象
					if(items.length>0){
						var thMoney = items[1].money;
						$("#THMoney").text(thMoney);//退还金额
						$("#cityName").text(obj.province_city);
						$("#plan_time").text(obj.plan_time);
						$("#plan_money_strong").text($.trim($("#planMoney").val()));
						var itemStr ="";
						$.each(items,function(index,obj1){
							if(obj1.type=="head"){
								if(index>0 || index!=(items.length-1) ){
									itemStr += "</li>";
								}
								itemStr += "<li>";
								itemStr += "<div class='palnCont_listBox_topBox'>"+obj1.time+"</div>";
							}else if(obj1.type=="消费")	{
								itemStr += "<div class='palnCont_listBox_bottomBox'>";
								itemStr += "<img src='/ksdH5/img/planList/huankuanfangshi.png'/>";
								itemStr += "<strong>"+obj1.type+"</strong>";
								itemStr += "<span class='palnCont_color_lvse'>"+obj1.status+"</span>";
								itemStr += "<em>"+obj1.money+"</em>";
								itemStr += "</div>";
							}else if(obj1.type=="还款") {
								itemStr += "<div class='palnCont_listBox_bottomBox'>";
								itemStr += "<img src='/ksdH5/img/planList/hkfs_hsIcon.png' />";
								itemStr += "<strong>"+obj1.type+"</strong>";
								itemStr += "<span class='palnCont_color_lvse'>"+obj1.status+"</span>";
								itemStr += "<em>"+obj1.money+"</em>";
								itemStr += "</div>";
							}	
						})
						$("#item_list_ul").html(itemStr);
					}
					 $('.planCont_xkBg').show();
					   $('.planContBox').show();	
					//返回计划列表
					//window.history.go(-1);
				} else {
					mui.toast(re.msg,{ duration:'long'});
				}
			}
		}); 
		
		
		
	}
	
//监听绑定触发查询计划详情的事件	
$(function(){
	 $(".change_input").bind("input propertychange",function(){
		 clearIput();
	}) 
//
   $('.select-value').mPicker({
       level:2,
       dataJson:dataJson,
       Linkage:true,
       rows:6,
       idDefault:true,
       splitStr:'-',
       header:'<div class="mPicker-header">请选择城市</div>',
       confirm:function(){
           //更新json
           /*this.container.data('mPicker').updateData(level3);*/
           //console.info($('.select-value').data('value1')+'-'+$('.select-value').data('value2'));
    	  clearIput();
       },
       cancel:function(){
           //console.info($('.select-value').data('value1')+'-'+$('.select-value').data('value2'));
       }
   })
	
})


//验证输入信息请求后台获得计划详情	
function getItems(){
	clearIput();
	if(currentCardNo==""||currentCardId==""){
		mui.toast("请选择信用卡",{ duration:'long'});
		return false;
	}
	var cityName =$("#city_input").val();
	if("请选择城市"==cityName){
		mui.toast("请选择城市",{ duration:'long'});
		return false;
	}
	var planMoney = $("#planMoney").val();
	if(""==planMoney || planMoney==null){
		mui.toast("请输入还款金额",{ duration:'long'});
		return false;
	}
	var dateStr =times;
	if(timeArray.length<2){
		mui.toast("日期最少选择两天",{ duration:'long'});
		return false;
	}
	var cardNo = currentCardNo;
	var bindID =currentCardId;
	  $.ajax({
			url : ctx+ "h5/plan/add",
			type : "POST",
			async: false,
			data:{
				"cityName":cityName,
				"planMoney":planMoney,
				"dateStr":dateStr,
				"cardNo":cardNo,
				"second":second,
				"bindID":bindID
			},
			success : function(re) {
			if(re.status == "out"){
				//跳转登陆页面
				location.href = ctx + 'h5/login';
			}	
			if (re.status == "SUCCESS") {
				var obj = re.obj;
			   kt_phone = obj.kt_phone;
			    if(kt_phone != null ){
			    	//弹出开通通道提示框
					checkAcqKt();
					acqCode = obj.kt_code;
			    	return false;
			    }else {
			    	iskt = true;
			    }
				list = obj.list;
				acqCode = obj.acq_code;
				var bigfl = obj.bigfl;//大额费率
				var free_free = obj.free_free;//手续费的手续费
				$("#free_free").text(free_free.toFixed(2));
				var plan_time = obj.plan_time;//执行时间区间 例如2019/07/17 - 2019/07/19
				planDate = plan_time;
				var province_city = obj.province_city; //落地城市 例如：湖北省-武汉市
				var rate_money = obj.rate_money;
				$("#rate_money").text(rate_money.toFixed(2));
				var sbigorsmall = obj.sbigorsmall; //大额 或者 小额
				$("#sbigorsmall").text(sbigorsmall);
				var scale = obj.scale; //当前费率
				$("#scale").text(scale);
				var second = obj.second; //每天执行次数 
				$("#second").text(second);
				var smallfl = obj.smallfl; //小额费率
				var times_money = obj.times_money; //笔数费
				$("#times_money").text(times_money.toFixed(2));
				var toalFree = obj.toalFree; //手续费总额
				$("#toalFree").text(toalFree.toFixed(2));
				var total_zhj = obj.total_zhj; //周转金
				$(".total_zhj").text(total_zhj.toFixed(2));
				bigRate = bigfl
				smallRate = smallfl;
				 //接收计划明细
				var items =$.parseJSON(obj.formatItmes) ;//把json字符串转javascript json对象
				if(items.length>0){
					var thMoney = items[2].money;
					$("#THMoney").text(thMoney);//退还金额
					$("#cityName").text(obj.province_city);
					$("#plan_time").text(obj.plan_time);
					$("#plan_money_strong").text($.trim($("#planMoney").val()));
				}	
				//返回计划列表
				//window.history.go(-1);
				return true;
			} else {
				clearIput();
				mui.toast(re.msg,{ duration:'long'});
				return false;
			}
		}
	}); 
}	

//显示交易密码提示框
function showTransPassord(){
	var total_zhj = $("#total_zhj").text();
	if(total_zhj==""){
		mui.toast("请先点击显示周转金",{ duration:'long'});
		return;
	}
	
	if(currentCardNo==""||currentCardId==""){
		mui.toast("请选择信用卡",{ duration:'long'});
		return;
	}
	var planMoney = $.trim($("#planMoney").val());
	if(""==planMoney || planMoney==null){
		mui.toast("输入还款金额",{ duration:'long'});
		return;
	}
	var dateStr =times;
	if(timeArray.length<2){
		mui.toast("日期最少选择两天",{ duration:'long'});
		return;
	}
	if(""==second || second==null){
		mui.toast("请选择还款次数",{ duration:'long'});
		return;
	}
	var cityName = $.trim($("#city_input").val());
	if("请选择城市"==cityName){
		mui.toast("请选择城市",{ duration:'long'});
		return;
	}
	//没有开通通道
	if(!iskt){
		checkAcqKt();
    	return;
	}
	$(".tradePassword_tishiBox").show();
	$(".tradePassword_tishiBg").show();
}



//提交计划
function submitPlan(){
	//没有开通通道
	if(!iskt){
		$(".selectChannelBox_tishiBg").show();
		$(".selectChannelBox_tishiBox").show();
    	return;
	}
	if(currentCardNo==""||currentCardId==""){
		mui.toast("请选择信用卡",{ duration:'long'});
		return;
	}
	var planMoney = $.trim($("#planMoney").val());
	if(""==planMoney || planMoney==null){
		mui.toast("输入还款金额",{ duration:'long'});
		return;
	}
	var dateStr =times;
	if(timeArray.length<2){
		mui.toast("日期最少选择两天",{ duration:'long'});
		return;
	}
	if(""==second || second==null){
		mui.toast("请选择还款次数",{ duration:'long'});
		return;
	}
	var cityName = $.trim($("#city_input").val());
	if("请选择城市"==cityName){
		mui.toast("请选择城市",{ duration:'long'});
		return;
	}
	
	var cbAmt= $.trim($("#total_zhj").text());//周转金
	var scale = $.trim($("#scale").text());//当前费率
	var dateArray = planDate.split("-");
	var  endTime =dateArray[1];
	var tranPassword = $.trim($("#tranPassword").val());//交易密码
	var passwordLen = tranPassword.length;
	if(passwordLen!=6){
		mui.toast("请输入正确的交易密码",{ duration:'long'});
		return;
	}
	var rate_money = $.trim($("#rate_money").text());//手续费
	var times_money = $.trim($("#times_money").text());//笔数费
	var toalFree = $.trim($("#toalFree").text());//笔数费
	var free_free = $.trim($("#free_free").text());//手续费的手续费
	var cardNo = currentCardNo;
	var bindID =currentCardId;
	  $.ajax({
			url : ctx+ "h5/plan/submitPlan",
			type : "POST",
			data:{
				"cityName":cityName,
				"acqCode":acqCode,
				"planAmt":planMoney,//计划金额
				"cbAmt":cbAmt,//周转金
				"planList":list,//计划明细列表
				"rate":scale,//当前执行的费率
				"endTime":endTime,//结束时间（2019-02-19）
				"tranPassword":tranPassword,//交易密码
				"rate_money":rate_money,//费率手续费
				"times_money":times_money,//笔数费
				"toalFree":toalFree,//总费用
				"free_free":free_free,//总费用
				"everyNum":second
			},
			success : function(re) {
			if(re.status == "out"){
				//跳转登陆页面
				location.href = ctx + 'h5/login';
			}	
			if (re.status == "SUCCESS") {
				$(".tradePassword_tishiBox").hide();
				//返回计划列表
				mui.toast(re.msg,{ duration:'long'});
				setTimeout(function (){
					location.href = ctx + 'h5/plan/list';
				}, 3000);
				
			} else {
				mui.toast(re.msg,{ duration:'long'});
			}
		}
	}); 
}
var open_acq_result;
//发送开通通道验证码
function getOpenCode(){
	  $.ajax({
			url : ctx+ "h5/plan/sendOpenAcqCode",
			type : "POST",
			data:{
				"acqcode":acqCode,
				"cardid":currentCardId
			},
			success : function(re) {
			if(re.status == "out"){
				//跳转登陆页面
				location.href = ctx + 'h5/login';
			}	
			if (re.status == "SUCCESS") {
				open_acq_result = re.obj.result;
				mui.toast(re.msg,{ duration:'long'});
			} else {
				mui.toast(re.msg,{ duration:'long'});
			}
		}
	}); 
}

//确定开通通道
function submitAcq(){
	var smscode = $.trim($("#open_acq_code").val());//短信验证码
	 $.ajax({
			url : ctx+ "h5/plan/submitAcq",
			type : "POST",
			data:{
				"smscode":smscode,
				"result":open_acq_result,
				"acqcode":acqCode,
				"cardid":currentCardId
			},
			success : function(re) {
			if(re.status == "out"){
				//跳转登陆页面
				location.href = ctx + 'h5/login';
			}	
			if (re.status == "SUCCESS") {
				//开通成功
				iskt = true;
				$(".selectChannelBox_tishiBg").hide();
				$(".selectChannelBox_tishiBox").hide();
				mui.toast(re.msg,{ duration:'long'});
			} else {
				mui.toast(re.msg,{ duration:'long'});
			}
		}
	}); 
}
//未开通通道的执行方法
function checkAcqKt(){
	$("#open_bank_phone").text(kt_phone.substr(0,4)+"***"+kt_phone.substr(7,11));
	var len = currentCardNo.length-8;
	var str="";
	for(var i=0;i<len;i++){
		str+="*";
	}
	$("#open_acq_cardno").text(currentCardNo.substr(0,4)+str+currentCardNo.substr(currentCardNo.length-4));
	$(".selectChannelBox_tishiBg").show();
	$(".selectChannelBox_tishiBox").show();
	
}

//清空表单信息
function clearIput(){
	$("#free_free").text("");
	$("#rate_money").text("");
	$("#sbigorsmall").text("");
	$("#THMoney").text("");
	$("#scale").text("");
	$("#second").text("");
	$("#times_money").text("");
	$("#toalFree").text("");
	$(".total_zhj").text("");
}


</script>

</html>
